package games.swingPlus;

import graphics.Sprite2D;
import hardware.Display2D;
import hardware.UI;


public class Caret extends Sprite2D {


public static final short EMPTY_COLOR = 0x333;	
	

	int xVector;
	int yVector;
	int movieCounter;
	int moviePenality;
	
	short load;
	
public static byte accXRef =0;
	
	
public void init()
{
	
	color=EMPTY_COLOR;
	
	xPos=Display2D.getColumnCount()/2;
	yPos=Display2D.getRowCount()-3;
	visible=true;
	movieCounter=0;
	moviePenality=10;
	accXRef=UI.getAccAxis(UI.ACC_AXIS_X);
	
}
	
	
public void setColor(int color)
{
	
}



public void move()
{
	if (movieCounter==moviePenality)
		{
		xPos+=xVector;
		xVector=0;
		movieCounter=0;
		}
	else
	{
		movieCounter++;
	}
	
}


public void setMoveVector()
{
	
	if ((hardware.UI.keyLRight() & (xPos<(Display2D.getColumnCount()-1))))
			{
			xVector=1;
			}

		else if (hardware.UI.keyLLeft() & (xPos>0))
			{
			xVector=-1;					
			}
	
	
	//if (useACC)
/*	
	int accX;
	
	
	accX=UI.getAccAxis(UI.ACC_AXIS_X);
	
	
	if ((accX>(accXRef+5))  & (xPos>0))
		{
		xVector=-1;
		}
	else if((accX<(accXRef-5) & (xPos<(Display2D.getColumnCount()-1))))
		{
		xVector=1;
		}

	*/

			
	
	//TODO ACC
}


public short load(short color)
{
	short oldColor;
	
	
	oldColor=load;
	load=color;
	
	this.color= color;
	
	return(oldColor);
}

}
